package com.cloud.alarm.dinger.bytetalk.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.io.Serial;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * @description:
 * @author: zhou shuai
 * @date: 2024/7/12 17:23
 * @version: v1
 */
@Getter
public class ByteCard implements Serializable {

    @Serial
    private static final long serialVersionUID = -3633027873644367348L;

    /**
     * 卡片标题
     */
    private final Header header;
    /**
     * 卡片正文
     */
    private final List<Content> elements;

    public ByteCard(String title, String content) {
        this.header = new Header(title);
        this.elements = Collections.singletonList(new Content("markdown", content));
    }

    /**
     * 卡片标题
     */
    @Getter
    public static class Header implements Serializable {

        @Serial
        private static final long serialVersionUID = 4875430682305343737L;

        /**
         * 标题主题颜色
         */
        private final String template;
        /**
         * 卡片主标题
         */
        private final Content title;

        public Header(String title) {
            this.template = "red";
            this.title = new Content("plain_text", title);
        }
    }

    /**
     * 组件
     */
    @Getter
    @AllArgsConstructor
    public static class Content {

        /**
         * 组件标签
         */
        private final String tag;

        /**
         * 组件内容
         */
        private final String content;

    }

}
